package com.k7.mobile.platform.web.action.admin;

import java.text.SimpleDateFormat;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.k7.mobile.platform.bo.ILogBO;
import com.k7.mobile.platform.dataobject.LogDO;
import com.k7.mobile.platform.web.action.BaseAction;

/**
 * 日志后台管理
 * @author lx
 *
 */
public class LogManageAction extends BaseAction{
	
	private static final long serialVersionUID = -5581897070979714532L;

	private ILogBO logBO;
	
	private Long userId;
	private Integer logType;
	private Integer optType;
	private Integer page;
	private String beginTime;
	private String endTime;
	
	private List<LogDO> list;
	private LogDO queryDO;
	
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public List<LogDO> getList() {
		return list;
	}

	public LogDO getQueryDO() {
		return queryDO;
	}

	public void setLogBO(ILogBO logBO) {
		this.logBO = logBO;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Integer getLogType() {
		return logType;
	}

	public void setLogType(Integer logType) {
		this.logType = logType;
	}

	public Integer getOptType() {
		return optType;
	}

	public void setOptType(Integer optType) {
		this.optType = optType;
	}

	public String getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	/**
	 * 日志列表页
	 * @return
	 * @throws Exception
	 */
	public String list() throws Exception{
		queryDO = new LogDO();
		
		if(userId != null)
			queryDO.setUserId(userId);
		if(logType != null)
			queryDO.setLogType(logType);
		if(optType != null)
			queryDO.setOptType(optType);
		if(!StringUtils.isBlank(beginTime))
			queryDO.setBeginTime(sdf.parse(beginTime + " 00:00:00"));
		if(!StringUtils.isBlank(endTime))
			queryDO.setEndTime(sdf.parse(endTime + " 23:59:59"));
		
		
		//设置分页
		if(page == null)
			page = 1;
		queryDO.setToPage(page);
		
		list = logBO.getLogList(queryDO);
		
		return SUCCESS;
	}
	
}
